var express = require("express");
var router = express.Router();
const Result = require("../utils/result");
const collectService = require("../services/collectService");

// 收藏
router.get("/", async function (req, res) {
  const { userId, collectType, id } = req.query;
  await collectService.collect(userId, collectType, id);
  res.json(Result.success());
});
// 取消收藏
router.get("/uncollect", async function (req, res) {
  const { userId, collectType, id } = req.query;
  await collectService.uncollect(userId, collectType, id);
  res.json(Result.success());
});

//获取列表
router.get('/list',async function (req, res){
  const userId = req.query.userId;
  const topicArr = await collectService.getList(userId);
  res.json(Result.success({topicArr}))
})

module.exports = router;
